/*
 * $Id: RequestDefn2SweepPropertiesDAO.java,v 1.4 2009/07/10 15:18:36 navdeep_mahajan Exp $
 * 
 * Copyright (C) 2006 General Electric Company. All Rights Reserved.
 * 
 * This software is the confidential and proprietary information of the General
 * Electric Company (GE). You shall not disclose this software and shall use it
 * only in accordance with the terms of the license agreement you entered into
 * with GE.
 * 
 * GE MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE
 * SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED
 * WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR
 * NON-INFRINGEMENT. GE SHALL NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE
 * AS A RESULT OF USING, MODIFYING, OR DISTRIBUTING THIS SOFTWARE OR ITS
 * DERIVATIVES.
 */
package com.ge.healthcare.autosc.common.database.dao;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springmodules.cache.annotations.Cacheable;

import com.ge.healthcare.autosc.common.ASCUtil;
import com.ge.healthcare.autosc.common.database.pojo.CfgRequestDefnToSweepProp;
import com.ge.healthcare.autosc.common.database.pojo.CfgSweepProperties;

/**
 * @author 212042764
 * 
 */
public class RequestDefn2SweepPropertiesDAO extends BaseDAO implements
		IRequestDefn2SweepPropertiesDAO {
	/**
	 * Eclispe generated
	 */
	private static final long serialVersionUID = -3129347140536131611L;
	public static final String TABLE_NAME = "com.ge.healthcare.autosc.common.database.pojo.CfgRequestDefnToSweepProp";
	public static final String REQUEST_DEFN_ID = "id.requestDefnId";

	public RequestDefn2SweepPropertiesDAO() {
		super(TABLE_NAME);
	}

	/**
	 * @see com.ge.healthcare.autosc.common.database.dao.ISweepPropertiesDAO#getSweepPropForRequestDefn(java.lang.Long)
	 */
	@Cacheable(modelId = "RequestDefn2SweepPropDAOCacheModel")
	public Map<String, String> getSweepPropForRequestDefn(Long requestDefnId) {
		if (ASCUtil.isNullOrEmptyObject(requestDefnId)) {
			return null;
		}
		List<?> rtvdProperties = this.findByProperty(REQUEST_DEFN_ID,
				requestDefnId);
		if (ASCUtil.isNullOrEmptyList(rtvdProperties)) {
			return null;
		}
		Map<String, String> sweepProperties = new HashMap<String, String>();
		for (int iCount = 0; iCount < rtvdProperties.size(); iCount++) {
			CfgSweepProperties sweepProperty = ((CfgRequestDefnToSweepProp) rtvdProperties
					.get(iCount)).getId().getCfgSweepProperties();
			sweepProperties.put(sweepProperty.getPropName().trim(),
					sweepProperty.getPropValue().trim());
		}
		return sweepProperties;
	}

	/**
	 * @see com.ge.healthcare.autosc.common.database.dao.BaseDAO#save(java.lang.Object)
	 */
	public void save(Object pojo) {
		super.save(pojo);
	}

	/**
	 * @see com.ge.healthcare.autosc.common.database.dao.IRequestTypeDAO#saveAlways(java.lang.Object)
	 */
	public void saveAlways(Object pojo) {
		super.save(pojo);
	}

	/**
	 * @see com.ge.healthcare.autosc.common.database.dao.BaseDAO#deleteByID(java.lang.Object)
	 */
	public void deleteByID(Object pojo) {
		super.deleteByID(pojo);
	}

	/**
	 * @see com.ge.healthcare.autosc.common.database.dao.BaseDAO#refresh(java.lang.Object)
	 */
	public void refresh(Object pojo) {
		super.refresh(pojo);
	}
}
